<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
  var cut = prompt("请输入样例：");
   // var cut = [ 3, 4, 5, 6, 7, 8 , 9];

    var cutarr = new Array();
    var tmp = new Array();
    var k = 0;
    for(var i = 0;i < cut.length;i++)
{ 
    cutchar = cut[i];//将数组元素存入cutchar中
    if(cut[i] == ' ')//遇到空格停下判断开始切割字符
{
    tmp[k++] = cutarr[0];//将纯入的字符插入tmp中，再滞空cutarr
    cutarr = '';
}
else{
    cutarr =cutarr + cutchar;//如果没遇到空格，继续向cutarr插入字符
}
}
if(cutarr.length > 0)//如果cutarr还有多余的字符将其插入tmp中
{
    tmp[k] = cutarr;
}

alert("数组长度是："+ tmp.length +"  数组元素："+ tmp.join(","));
console.log(tmp);
</script>